1 //+SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS+
\r
2 //| Heiken AshiR.mq4 |
\r
3 //| Copyright c 2004, MetaQuotes Software Corp. |
\r
4 //| http://www.metaquotes.net |
\r
5 //+SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS+
\r
6 //+------------------------------------------------------------------+
\r
7 //| For Heiken Ashi we recommend next chart settings ( press F8 or |
\r
8 //| select on menu 'Charts'->'Properties...'): |
\r
9 //| - On 'Color' Tab select 'Black' for 'Line Graph' |
\r
10 //| - On 'Common' Tab disable 'Chart on Foreground' checkbox and |
\r
11 //| select 'Line Chart' radiobutton |
\r
12 //+------------------------------------------------------------------+
\r
13 #property copyright "Copyright © 2004, MetaQuotes Software Corp."
\r
14 #property link "http://www.metaquotes.net"
\r
15 //---- îòðèñîâêà èíäèêàòîðà â ãëàâíîì îêíå
\r
16 #property indicator_chart_window
\r
17 //---- êîëè÷åñòâî èíäèêàòîðíûõ áóôôåðîâ
\r
18 #property indicator_buffers 4
\r
19 //---- öâåòà èíäèêàòîðà
\r
20 #property indicator_color1 Red
\r
21 #property indicator_color2 LimeGreen
\r
22 #property indicator_color3 Red
\r
23 #property indicator_color4 LimeGreen
\r
24 //---- òîëùèíà èíäèêàòîðíûõ ëèíèé
\r
25 #property indicator_width1 1
\r
26 #property indicator_width2 1
\r
27 #property indicator_width3 3
\r
28 #property indicator_width4 3
\r
29 //---- èíäèêàòîðíûå áóôôåðû
\r
34 //---- ïåðåìåííûå ñ ïëàâàþùåé òî÷êîé
\r
35 double haOpen, haHigh, haLow, haClose;
\r
36 //+SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS+
\r
37 //| Heiken AshiR initialization function |
\r
38 //+SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS+
\r
41 //---- ñòèëü èçîáðàæåíèÿ èíäèêàòîðà
\r
42 SetIndexStyle(0,DRAW_HISTOGRAM,0);
\r
43 SetIndexStyle(1,DRAW_HISTOGRAM,0);
\r
44 SetIndexStyle(2,DRAW_HISTOGRAM,0);
\r
45 SetIndexStyle(3,DRAW_HISTOGRAM,0);
\r
46 //---- óñòàíîâêà íîìåðà áàðà, íà÷èíàÿ ñ êîòîðîãî áóäåò îòðèñîâûâàòüñÿ èíäèêàòîð
\r
47 SetIndexDrawBegin(0,10);
\r
48 SetIndexDrawBegin(1,10);
\r
49 SetIndexDrawBegin(2,10);
\r
50 SetIndexDrawBegin(3,10);
\r
51 //---- 4 èíäèêàòîðíûõ áóôôåðà èñïîëüçîâàíû äëÿ ñ÷¸òà
\r
52 SetIndexBuffer(0,L.Buffer);
\r
53 SetIndexBuffer(1,H.Buffer);
\r
54 SetIndexBuffer(2,O.Buffer);
\r
55 SetIndexBuffer(3,C.Buffer);
\r
56 //---- çàâåðøåíèå èíèöèàëèçàöèè
\r
59 //+SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS+
\r
60 //| Heiken AshiiR teration function |
\r
61 //+SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS+
\r
64 if (Bars<=10) return(0);
\r
65 //----+ Ââåäåíèå öåëûõ ïåðåìåííûõ è ïîëó÷åíèå óæå ïîäñ÷èòàííûõ áàðîâ
\r
66 //---- áëîêèðîâàíèå ïåðåñ÷¸òà âñåõ ïîäñ÷èòàííûõ è îòðèñîâàííûõ áàðîâ ïðè ïîäêëþ÷åíèè ê èíòåðíåòó
\r
67 int bar,counted_bars=INDICATOR_COUNTED(0); INDICATOR_COUNTED(1);
\r
68 //---- ïðîâåðêà íà âîçìîæíûå îøèáêè
\r
69 if (counted_bars<0){INDICATOR_COUNTED(-1);return(-1);}
\r
70 //---- ïîñëåäíèé ïîäñ÷èòàííûé áàð äîëæåí áûòü ïåðåñ÷èòàí
\r
71 //(áåç ýòîãî ïåðåñ÷¸òà äëÿ counted_bars ôóíêöèÿ JJMASeries áóäåò ðàáîòàòü íåêîððåêòíî!!!)
\r
72 if (counted_bars>0) counted_bars--;
\r
73 //---- îïðåäåëåíèå íîìåðà ñàìîãî ñòàðîãî áàðà, íà÷èíàÿ ñ êîòîðîãî áóäåò ïðîèçåä¸í ïåðåñ÷¸ò íîâûõ áàðîâ
\r
74 bar=Bars-counted_bars-1;
\r
75 if (bar>Bars-2)bar=Bars-2;
\r
79 haOpen=(O.Buffer[bar+1]+C.Buffer[bar+1])/2;
\r
80 haClose=(Open[bar]+High[bar]+Low[bar]+Close[bar])/4;
\r
81 haHigh=MathMax(High[bar], MathMax(haOpen, haClose));
\r
82 haLow=MathMin(Low[bar], MathMin(haOpen, haClose));
\r
83 if (haOpen<haClose)
\r
85 L.Buffer[bar]=haLow;
\r
86 H.Buffer[bar]=haHigh;
\r
90 L.Buffer[bar]=haHigh;
\r
91 H.Buffer[bar]=haLow;
\r
93 O.Buffer[bar]=haOpen;
\r
94 C.Buffer[bar]=haClose;
\r
100 //+---------------------------------------------------------------------------------------------------------------------------+
\r
101 //----+ Ââåäåíèå ôóíêöèè INDICATOR_COUNTED (ôàéë INDICATOR_COUNTED.mqh ñëåäóåò ïîëîæèòü â ïàïêó (äèðåêòîðèþ):
\r
102 #include <INDICATOR_COUNTED.mqh> //////////////////////////////// MetaTrader\experts\include)
\r
103 //+---------------------------------------------------------------------------------------------------------------------------+